package com.sghd.candy.module.element.manager;

import com.sghd.common.ramcache.anno.Inject;
import com.sghd.common.ramcache.service.EntityCacheService;
import com.sghd.pojo.fight.game.ChessType;
import org.springframework.stereotype.Component;

import java.util.Comparator;
import java.util.List;

/**
 * @author Allen
 * @date 2018/12/14
 */
@Component
public class ElementConfigManager {
    @Inject
    private EntityCacheService<ChessType, ElementConfig> elementConfigCache;

    public ElementConfig getElementConfig(ChessType eleId) {
        return elementConfigCache.load(eleId);
    }

    void config(ElementConfig elementConfig, float dropRate) {
        elementConfig.config(dropRate);
    }

    void config(ElementConfig elementConfig, int level, UpgradeEle upgradeEle) {
        elementConfig.config(level, upgradeEle);
    }

    void config(ElementConfig elementConfig, float dropRate, int level, UpgradeEle upgradeEle) {
        elementConfig.config(dropRate);
        elementConfig.config(level, upgradeEle);
    }

    public List findAll() {
        return elementConfigCache.getFinder().sort(Comparator.comparing(ElementConfig::getEleId));
    }

}
